package com.ostms.adv.utils;

import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.security.MessageDigest;

public class Md5Util {
    private static final char[] a;

    public Md5Util() {
    }

    public static String MD5(String var0) {
        return MD5(var0, Charset.defaultCharset().name());
    }

    public static String MD5(byte[] var0) {
        if (var0 != null && var0.length != 0) {
            try {
                MessageDigest var1;
                (var1 = MessageDigest.getInstance("MD5")).update(var0);
                int var6;
                char[] var2 = new char[(var6 = (var0 = var1.digest()).length) << 1];
                int var3 = 0;

                for (int var4 = 0; var4 < var6; ++var4) {
                    var2[var3++] = a[var0[var4] >>> 4 & 15];
                    var2[var3++] = a[var0[var4] & 15];
                }

                return new String(var2);
            } catch (Exception var5) {
                var5.printStackTrace();
                return null;
            }
        } else {
            return null;
        }
    }

    public static String MD5(String var0, String var1) {
        if (var0 != null && var0.length() != 0) {
            try {
                return MD5(var0.getBytes(var1));
            } catch (UnsupportedEncodingException var2) {
                var2.printStackTrace();
                return null;
            }
        } else {
            return null;
        }
    }

    static {
        Md5Util.class.getSimpleName();
        a = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    }
}
